/**
 * Created by IntelliJ IDEA.
 * User: martlenn
 * Date: 24-Jan-2008
 * Time: 09:10:10
 */
package org.hkupp.db.accessors;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
/*
 * CVS information:
 *
 * $Revision$
 * $Date$
 */

/**
 * This class extends the Location_codeTableAccessor
 *
 * @author Lennart Martens
 * @version $Id$
 */
public class Location_code extends Location_codeTableAccessor {

    public Location_code(ResultSet aRs) throws SQLException {
        super(aRs);
    }

    public Location_code(HashMap aData) throws SQLException {
        super(aData);
    }


    /**
     * Returns the Location_code object for the specified code,
     * or 'null' if none was found.
     *
     * @param aConn Connection to retrieve the Location_code from.
     * @param aCode String with the location code to look up.
     * @return  Location_code for the specified code, or 'null' if none was found.
     * @throws  SQLException when the database could not be contacted.
     */
    public static Location_code findLocation_code(Connection aConn, String aCode) throws SQLException {
        Location_code result = null;
        Statement stat = aConn.createStatement();
        ResultSet rs = stat.executeQuery("select * from location_code where code = '" + aCode + "'");
        while(rs.next()) {
            result = new Location_code(rs);
        }
        return result;
    }
}
